#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include "uart.h"

#define HOST_COM_PORT 1
#define BUFFER_SIZE 1024

int main(void)
{
	int fd;
	char buff[BUFFER_SIZE];
	if((fd = open_port(HOST_COM_PORT)) < 0) /* 打开串口  */
	{
	 	perror("open_port");
	 	return 1;
	}

	if(set_com_config(fd, 115200, 8, 'N', 1) < 0) /* 配置串口  */
	 {
	 	perror("set_com_config");
	 	return 1;
	 }

	do
	{
		memset(buff, 0, BUFFER_SIZE);
		if (read(fd, buff, BUFFER_SIZE) > 0)
		{
			printf("The received words are : %s", buff);
		}
	} while(strncmp(buff, "quit", 4));

	close(fd);
	return 0;
}
